#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    bar=this->menuBar();
    this->setMenuBar(bar);
    //创建菜单
    QMenu *menu1=new QMenu(this);
    menu1->setTitle("菜单1");
    QMenu *menu2=new QMenu(this);
    menu2->setTitle("菜单2");
    QMenu *menu3=new QMenu(this);
    menu3->setTitle("菜单3");
    bar->addMenu(menu1);
    bar->addMenu(menu2);
    bar->addMenu(menu3);

    QAction *action1=new QAction(this);
    action1->setText("菜单项1");
    QAction *action2=new QAction(this);
    action2->setText("菜单项2");
    QAction *action3=new QAction(this);
    action3->setText("菜单项3");

    menu1->addAction(action1);
    menu1->addAction(action2);
    menu1->addAction(action3);
}

MainWindow::~MainWindow()
{
    delete ui;
}

